package com.eonmind.ai.mapper;

import com.eonmind.common.contract.data.base.BaseMongoMapper;
import com.eonmind.common.provider.entity.ai.AiUserModelConsumeHistory;
import com.mongoplus.conditions.query.QueryWrapper;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Xujie
 * @since 2025/5/29 21:22
 **/

@Component
public class AiUserModelConsumeHistoryMapper extends BaseMongoMapper<AiUserModelConsumeHistory> {
    public List<AiUserModelConsumeHistory> selectByDate(String startTime, String today, Long userId) {
        QueryWrapper<AiUserModelConsumeHistory> between = createMgoQuery()
                .eq(AiUserModelConsumeHistory::getUserId, userId)
                .between(AiUserModelConsumeHistory::getDataDate, startTime, today, false);
        return list(between);
    }

    public AiUserModelConsumeHistory selectByUserIdAndDate(Long userId, String todayString) {
        QueryWrapper<AiUserModelConsumeHistory> eq = createMgoQuery()
                .eq(AiUserModelConsumeHistory::getUserId, userId)
                .eq(AiUserModelConsumeHistory::getDataDate, todayString);
        return one(eq);
    }
}
